|
|
|
|
|
|
|
Besides the different constants for the icons, you can add to this parameter the constants for the buttons you want to appear. Table 11.2 presents a list of the different constants you can use for the buttons. |
|
|
|
|
| Table 11.2 Constants for the Buttons on the MsgBox. | | Button Constant | Description | | vbOkOnly | Displays the OK button only. This is the default. | | vbOkCancel | Displays both the OK and Cancel buttons. | | vbYesNo | Displays the Yes and No buttons. | | vbYesNoCancel | Displays the Yes, No, and Cancel buttons. | | vbRetryCancel | Displays the Retry and Cancel buttons. | | vbAbortRetryCancel | Displays the Abort, Retry, and Cancel buttons. | | vbMsgBoxHelpButton | Adds the Help button to the MsgBox. |
|
|
|
|
|
|
You can specify which button is the default button on the message box. This is accomplished by adding to the second parameter one of the vbDefaultButtonn constants. The n is the number of the button to set the focus to and can be a value from 1 to 4. |
|
|
|
 |
|
|
|
|
intButton = MsgBox("Save Data", vbQuestion + vbYesNo, "Save" |
|
|
|
|
|
|
|
|
You can try out some of the options by loading the sample project for this chapter and clicking the MsgBox command button on the main form to display a sample message box, as shown in Figure 11.1. |
|
|
|
|
|
|
|
|
Examples Filename: MsgBox.frm |
|
|
|
|
|
|
|
|
When you click the first command button on the MsgBox.frm sample form, youll see a message box appear (see Figure 11.1). |
|
|
|
|
|
|
|
|
Figure 11.1
A simple MsgBox example. |
|
|
|
|
|
|
|
|
You might use this simple type of message box when a long process completes or when you just need to inform the user of some simple information that needs an acknowledgment. |
|
|
|
|
|